package com.test.bool.ExpressionTest;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.WebDriver.Navigation;
import org.openqa.selenium.chrome.ChromeDriver;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;



public class App extends TestCase{
	private WebDriver driver;
	private Navigation navigation;

    /**
     * Create the test case
     *
     * @param testName name of the test case
     */
    public App( String testName )
    {
        super( testName );
    }

    /**
     * @return the suite of tests being tested
     */
    public static Test suite()
    {
        return new TestSuite( App.class );
    }

    public void setUp() throws Exception {
		//System.setProperty("webdriver.chrome.driver", "C:/Users/chen/AppData/Local/Google/Chrome/Application/chrome.exe");
	
		System.setProperty("webdriver.chrome.driver", "C:/Users/chen/AppData/Local/Google/Chrome/Application/chromedriver.exe");
    }
	

    public void tearDown() throws Exception {
    }


    public void testSearch() throws InterruptedException {
		driver = new ChromeDriver();
		driver.get("http://www.baidu.com");

        //getTitle()获取当前页面title的值    
        System.out.println("当前打开页面的标题是： "+ driver.getTitle());   
//        String html = driver.getPageSource();    
         
	//	Thread.sleep(1000000);
      
		//navigation = driver.navigate();
    	//navigation.to("https://www.baidu.com");

    	WebElement searchInput = driver.findElement(By.id("kw"));
    	searchInput.sendKeys("Junit");
    	
    	WebElement searchButton = driver.findElement(By.id("su"));
    	searchButton.click(); 
    	Thread.sleep(1000);
    	boolean rs;
    	try {
    		WebElement element = driver.findElement(By.id("content_left"));
    		rs = true;
    	} catch(Exception e) {
    		rs = false;
    	}
		driver.quit();
    	assertTrue(rs);
    }
    




}